package com.example.fragmentyeni;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class FragmentA extends Fragment implements OnItemClickListener {
	Communicator comm;
	ListView listView;
	View v;
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
			v = inflater.inflate(R.layout.fragment_layout_a, container, false);
			listView = (ListView)v.findViewById(R.id.listView1);
			ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.title, android.R.layout.simple_list_item_1);
			listView.setAdapter(adapter);
			listView.setOnItemClickListener(this);
			
			
			return v;
		
	}
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		
		comm.respond(position);
					
	}
	
	public void setCommunicator(Communicator c){
		comm =c;
		
	}
	public interface Communicator{
		public void respond(int index);
	}
	

}
